home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / func / trace_opts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  5.9 KB  |  239 lines

  1.  
  2. /*
  3.  * trace_opts.c
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <sys/param.h>
  8. #include <sys/types.h>
  9. #include "ui.h"
  10. #include "display.h"
  11. #include "trace_ui.h"
  12. #include "scale.h"
  13. #include "log.h"
  14. #include "reg.h"
  15.  
  16. struct trcontext *trace_by_lid();
  17.  
  18. extern trace_tcntrl_objects *trace_tcntrl;
  19. extern trace_trwin_objects *trace_twin;
  20.  
  21. static int save_scale_type, save_min, save_max;
  22.  
  23. /*****************************************************************/
  24. trace_opt_proc()
  25. {
  26.     if (trace_tcntrl == NULL)
  27.     return;
  28.  
  29.     if (((int) xv_get(trace_tcntrl->tcntrl, XV_SHOW, NULL)) == FALSE) {
  30.     xv_set(trace_tcntrl->tcntrl,
  31.            FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  32.     xv_set(trace_tcntrl->tcntrl,
  33.            XV_SHOW, TRUE, FRAME_CLOSED, FALSE, NULL);
  34.     } else {
  35.     xv_set(trace_tcntrl->tcntrl,
  36.            FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  37.     xv_set(trace_tcntrl->tcntrl,
  38.            XV_SHOW, FALSE, NULL);
  39.     }
  40.     return;
  41. }
  42.  
  43. /*****************************************************************/
  44. /* routine to update the control panel to reflect the status of the current
  45.    trace */
  46.  
  47. trace_panel(curtrace)
  48.     struct trcontext *curtrace;
  49. {
  50.     xv_set(trace_tcntrl->radius,
  51.        PANEL_VALUE, curtrace->t_attr.avgrad,
  52.        NULL);
  53.     xv_set(trace_tcntrl->scale,
  54.        PANEL_VALUE, curtrace->t_attr.scale_type,
  55.        NULL);
  56.     xv_set(trace_tcntrl->min,
  57.        PANEL_VALUE, curtrace->t_attr.axmin,
  58.        PANEL_MIN_VALUE, 0,
  59.        PANEL_MAX_VALUE, orig_img->maxv,
  60.        NULL);
  61.     xv_set(trace_tcntrl->max,
  62.        PANEL_VALUE, curtrace->t_attr.axmax,
  63.        PANEL_MIN_VALUE, 0,
  64.        PANEL_MAX_VALUE, orig_img->maxv,
  65.        NULL);
  66.  
  67.     save_scale_type = curtrace->t_attr.scale_type;
  68.     save_min = curtrace->t_attr.axmin;
  69.     save_max = curtrace->t_attr.axmax;
  70. }
  71.  
  72. /*****************************************************************/
  73. void
  74. trace_opt_reset(item, event)
  75.     Panel_item item;
  76.     Event    *event;
  77. {
  78. #ifdef DEBUG
  79. #endif
  80.     fputs("trace: trace_opt_reset (not yet done!) \n", stderr);
  81.  
  82.     xv_set(trace_tcntrl->scale,
  83.        PANEL_VALUE, save_scale_type,
  84.        NULL);
  85.     xv_set(trace_tcntrl->min,
  86.        PANEL_VALUE, save_min,
  87.        NULL);
  88.     xv_set(trace_tcntrl->max,
  89.        PANEL_VALUE, save_max,
  90.        NULL);
  91. }
  92.  
  93. /*****************************************************************/
  94. Panel_setting
  95. traceno_proc(item, event)
  96.     Panel_item item;
  97.     Event    *event;
  98. {
  99.     int       value = (int) xv_get(item, PANEL_VALUE);
  100.     struct trcontext *context;
  101.  
  102.     if (value < 1) {
  103.     xv_set(item, PANEL_VALUE, 1, NULL);
  104.     return panel_text_notify(item, event);
  105.     }
  106.     if (value > get_current_lid()) {
  107.     xv_set(item, PANEL_VALUE, get_current_lid(), NULL);
  108.     return panel_text_notify(item, event);
  109.     }
  110.  
  111.     context = trace_by_lid(value);
  112.  
  113.     if (context == NULL) {
  114.     panel_text_notify(item, event);
  115.     return panel_text_notify(item, event);
  116.     }
  117.     trace_panel(context);
  118. #ifdef DEBUG
  119.     fprintf(stderr, "trace: traceno_proc: value: %d\n", value);
  120. #endif
  121.     panel_text_notify(item, event);
  122.     return panel_text_notify(item, event);
  123. }
  124.  
  125.  
  126. /*****************************************************************/
  127. /*
  128.  * Notify callback function for `scale'.
  129.  */
  130. void
  131. scale_proc(item, value, event)    /* change scale type */
  132.     Panel_item item;
  133.     int       value;
  134.     Event    *event;
  135. {
  136.     struct trcontext *context;
  137.  
  138.     context = trace_by_lid(xv_get(trace_tcntrl->traceno, PANEL_VALUE, NULL));
  139.     if (context == NULL) {
  140.     panel_text_notify(item, event);
  141.     return;
  142.     }
  143.     context->t_attr.scale_type = value;
  144.  
  145.     scale_trace(context);
  146.     trace_panel(context);
  147.     /* repaint the window */
  148.     trcanv_repaint_proc(context->win_info->trcanv, context->trpntw, display,
  149.             context->trxid, (Xv_xrectlist *) NULL);
  150. #ifdef DEBUG
  151.     fprintf(stderr, "trace: scale_proc: value: %u\n", value);
  152. #endif
  153. }
  154.  
  155. /*****************************************************************/
  156. /*
  157.  * Notify callback function for `radius'.
  158.  */
  159. Panel_setting
  160. rad_proc(item, event)
  161.     Panel_item item;
  162.     Event    *event;
  163. {
  164.     int       value = (int) xv_get(item, PANEL_VALUE);
  165.     struct trcontext *context;
  166.  
  167. #ifdef DEBUG
  168.     fprintf(stderr, "trace: rad_proc: value: %d\n", value);
  169. #endif
  170.     context = trace_by_lid(xv_get(trace_tcntrl->traceno, PANEL_VALUE, NULL));
  171.     if (context == NULL) {
  172.     return panel_text_notify(item, event);
  173.     }
  174.     context->t_attr.avgrad = value;
  175.  
  176.     /* repaint the window */
  177.     trcanv_repaint_proc(context->win_info->trcanv, context->trpntw, display,
  178.             context->trxid, (Xv_xrectlist *) NULL);
  179.     return panel_text_notify(item, event);
  180. }
  181.  
  182. /*****************************************************************/
  183. /*
  184.  * Notify callback function for `min'.
  185.  */
  186. Panel_setting
  187. min_proc(item, event)
  188.     Panel_item item;
  189.     Event    *event;
  190. {
  191.     int       value = (int) xv_get(item, PANEL_VALUE);
  192.     struct trcontext *context;
  193.  
  194. #ifdef DEBUG
  195.     fprintf(stderr, "trace: min_proc: value: %d\n", value);
  196. #endif
  197.     context = trace_by_lid(xv_get(trace_tcntrl->traceno, PANEL_VALUE, NULL));
  198.     if (context == NULL) {
  199.     return panel_text_notify(item, event);
  200.     }
  201.     context->t_attr.scale_type = 2;
  202.     scale_trace(context);
  203.     trace_panel(context);
  204.  
  205.     /* repaint the window */
  206.     trcanv_repaint_proc(context->win_info->trcanv, context->trpntw, display,
  207.             context->trxid, (Xv_xrectlist *) NULL);
  208.     return panel_text_notify(item, event);
  209. }
  210.  
  211. /*****************************************************************/
  212. /*
  213.  * Notify callback function for `max'.
  214.  */
  215. Panel_setting
  216. max_proc(item, event)
  217.     Panel_item item;
  218.     Event    *event;
  219. {
  220.     int       value = (int) xv_get(item, PANEL_VALUE);
  221.     struct trcontext *context;
  222.  
  223. #ifdef DEBUG
  224.     fprintf(stderr, "trace: max_proc: value: %d\n", value);
  225. #endif
  226.     context = trace_by_lid(xv_get(trace_tcntrl->traceno, PANEL_VALUE, NULL));
  227.     if (context == NULL) {
  228.     return panel_text_notify(item, event);
  229.     }
  230.     context->t_attr.scale_type = 2;
  231.     scale_trace(context);
  232.     trace_panel(context);
  233.  
  234.     /* repaint the window */
  235.     trcanv_repaint_proc(context->win_info->trcanv, context->trpntw, display,
  236.             context->trxid, (Xv_xrectlist *) NULL);
  237.     return panel_text_notify(item, event);
  238. }
  239.